"use strict";
// 可被混入的功能类
class CanEat {
    constructor() {
        this.name = "Zkdsads";
    }
    eat() {
        console.log("I can eat");
    }
}
class CanWalk {
    constructor() {
        this.age = 12;
    }
    walk() {
        console.log("I can walk");
    }
}
// 混入函数的目标类（必须为空实现）
class PersonMinx {
    constructor() {
        this.age = 1;
        this.name = "dasd";
    }
}
// 实现混入
function applyMixins(targetClass, baseClasses) {
    baseClasses.forEach(baseClass => {
        console.dir(Object.getOwnPropertyNames(baseClass.prototype));
        Object.getOwnPropertyNames(baseClass.prototype).forEach(name => {
            if (name !== 'constructor') {
                Object.defineProperty(targetClass.prototype, name, Object.getOwnPropertyDescriptor(baseClass.prototype, name));
            }
        });
    });
}
applyMixins(PersonMinx, [CanEat, CanWalk]);
// 使用
const p2 = new PersonMinx();
p2.eat(); // I can eat
p2.walk(); // I can walk
console.log(p2.age);
